<?php
session_start();
require_once "functions.php";
$member_id=$_SESSION['member_id'];
$get_request=mysql_query("SELECT COUNT(*) as cc from member_request_member m
            INNER JOIN request r ON (m.request_id = r.request_id) WHERE m.member_id2 = {$member_id} AND m.approve is NULL")
        or die(mysql_error());
$Mcount=mysql_fetch_assoc($get_request);
$count=$Mcount['cc'];
//echo '(',$count,')';

$check_Mainorganizer=mysql_query("SELECT * FROM conference
                       WHERE creator_id ='$member_id'") or die(mysql_error());
//enter the while loop only if the current user is a main organizer in one of the conferences
$ct=0;

$total=$count;
While($row=mysql_fetch_assoc($check_Mainorganizer))
{
    // take the conference id and the name of the conference
    $conference_id=$row['conference_id'];
    //$conference_name = $row['long_name'];
//check whether this conference has any requests or not
    $has_Request=mysql_query("SELECT Count(*) as ct FROM  member_subscribesto_conference
                       WHERE conference_id ='$conference_id' AND approve is NULL") or die(mysql_error());
    while($row=mysql_fetch_assoc($has_Request))
    {
        $ct=$row['ct'];
        $total += $ct;
    }
}
//$total += $ct;
//$total += $count;
echo $total;
?>
